using System;

public class tk2dTextWrap<ValType>
{
	public tk2dTextWrap(tk2dTextMesh _mesh)
	{
		this.mesh = _mesh;
	}

	public tk2dTextWrap(tk2dTextMesh _mesh, ValType initVal, string formatStr = "")
	{
		this.mesh = _mesh;
		this.setValue(initVal);
	}

	public ValType Value
	{
		get
		{
			return this.myValue;
		}
		set
		{
			if (!value.Equals(this.myValue))
			{
				this.myValue = value;
				if (this.customConv != null)
				{
					string text = this.customConv(this.myValue);
					if (this.mesh.text != text)
					{
						this.mesh.text = text;
						this.mesh.Commit();
					}
				}
				else
				{
					this.mesh.From(this.myValue);
				}
			}
		}
	}

	private void setValue(ValType val)
	{
		this.myValue = val;
		this.mesh.From(this.myValue);
	}

	public void SetCustomConverter(tk2dTextWrap<ValType>.customConverter conv)
	{
		this.customConv = conv;
	}

	public tk2dTextMesh mesh;

	private ValType myValue;

	private tk2dTextWrap<ValType>.customConverter customConv;

	public delegate string customConverter(ValType val);
}
